package com.uchiyou.walletwrapper.util;

import com.googlecode.jsonrpc4j.Base64;
import com.googlecode.jsonrpc4j.JsonRpcHttpClient;

import java.net.URL;
import java.util.HashMap;
import java.util.Map;

public class ClientUtil {



    public static JsonRpcHttpClient getClient(){
        // 身份认证
        String cred = Base64.encodeBytes((Constants.RPC_USER + ":" + Constants.RPC_PASSWORD).getBytes());
        Map<String, String> headers = new HashMap<>(1);
        headers.put("Authorization", "Basic " + cred);
        try {
            JsonRpcHttpClient client = new JsonRpcHttpClient(new URL("http://" + Constants.RPC_ALLOWIP + ":" + Constants.RPC_PORT), headers);
            return client;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
